
/****** Object:  StoredProcedure [dbo].[web_update_register]    Script Date: 10/19/2013 09:22:25 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'web_update_register')
DROP PROCEDURE web_update_register
GO

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[web_update_register] 
	@id int,
	@eil_nr varchar(10),
	@imcode varchar(12),
	@impav varchar(70),
	@prcode varchar(12),
	@prpav varchar(40),
	@tipas int
AS
BEGIN
	

	SET NOCOUNT ON

	if not @eil_nr like '%[^0-9]%'	
	begin
		SET @eil_nr  = (SELECT max(n90_eil_nr) FROM N90_REGISTRAS where n90_tipas = @tipas)
		If @eil_nr is not null
			SET @eil_nr  = @eil_nr + 1
		else
			SET @eil_nr  = 1
	end
	
	update N90_REGISTRAS  SET
	 n90_kodas_ks=@imcode,
	 n90_pav=@impav,
	 n90_kodas=@prcode,
	 n90_pav1=@prpav,
	 n90_tipas=@tipas,
	 n90_eil_nr=@eil_nr
	 where N90_id = @id


END

GO

